/**
 * 
 */
package com.an.nopro.app.framework.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.an.nopro.app.framework.entity.Person;
import com.an.nopro.app.framework.entity.AxSmsStateReportParam;
/**
 * @author Administrator
 *
 */
@Controller
public class ThymeleafController {

	@ModelAttribute(name="person")
	public Person p() {
	
		Person person = new Person();
		person.setAddress("陕西");
		person.setAge(52);
		person.setName("张三");
		return person;
	}
	
	@RequestMapping("index")
	public String index(@ModelAttribute(name="person") Person person,Model model,HttpServletRequest request,AxSmsStateReportParam axSmsStateReportParam) {
		System.err.println("-------");
		System.out.println("person:0 " + person);
		System.out.println("请求信息：");
		System.out.println("axSmsStateReportParam:" + axSmsStateReportParam);
		System.out.println("request.getRemoteHost():" + request.getRemoteHost());
		System.out.println("request.getRemotePort():" + request.getRemotePort());
		System.out.println("request.getRequestURI():" + request.getRequestURI());
		System.err.println("-------");

		
		Person p = new Person("an安天池你好", 25);
		Person p2 = new Person("an安天池你好2", 26);
		Person p3 = new Person("an安天池你好3", 27);
		
		List<Person> list = new ArrayList<>();
		list.add(p3);
		list.add(p2);
		list.add(p);
		model.addAttribute("singlePerson", p);
		model.addAttribute("people", list);
		
		return "index";
	}
}
